/* $Id: GridTypeModelUnitTest.java 63 2010-02-14 13:52:34Z aaron.day $ */
package org.crazydays.gameplan.map.swing;


import org.junit.*;
import static org.junit.Assert.*;

import org.crazydays.gameplan.map.Geometry;
import org.crazydays.gameplan.map.GridType;

/**
 * GridTypeModelUnitTest
 */
public class GridTypeModelUnitTest
{
    /**
     * Test constructor.
     */
    @Test
    public void testConstructor()
    {
        // objects
        Geometry geometry = new Geometry(600, 800, GridType.SQUARE, 15);

        // test
        GridTypeModel model = new GridTypeModel(geometry);

        // verify
        assertEquals("geometry", geometry, model.geometry);
    }

    /**
     * Test getSize().
     */
    @Test
    public void testGetSize()
    {
        // objects
        Geometry geometry = new Geometry(600, 800, GridType.SQUARE, 15);

        // setup
        GridTypeModel model = new GridTypeModel(geometry);

        // test
        int result = model.getSize();

        // verify
        assertEquals("result", 3, result);
    }

    /**
     * Test getElementAt(int).
     */
    @Test
    public void testGetElementAt()
    {
        // objects
        Geometry geometry = new Geometry(600, 800, GridType.SQUARE, 15);

        // setup
        GridTypeModel model = new GridTypeModel(geometry);

        // test
        String result = (String) model.getElementAt(0);

        // verify
        assertEquals("result", GridType.TYPE_NAMES[GridType.SQUARE], result);
    }

    /**
     * Test getSelectItem().
     */
    @Test
    public void testGetSelectedItem()
    {
        // objects
        Geometry geometry = new Geometry(600, 800, GridType.ISOMETRIC, 15);

        // setup
        GridTypeModel model = new GridTypeModel(geometry);

        // test
        String result = (String) model.getSelectedItem();

        // verify
        assertEquals("result", GridType.TYPE_NAMES[GridType.ISOMETRIC], result);
    }

    /**
     * Test setSelectedItem(Object).
     */
    @Test
    public void testSetSelectedItem()
    {
        // objects
        Geometry geometry = new Geometry(600, 800, GridType.ISOMETRIC, 15);

        // setup
        GridTypeModel model = new GridTypeModel(geometry);

        // test
        model.setSelectedItem(GridType.TYPE_NAMES[GridType.HEXAGON]);

        // verify
        assertEquals("geometry.gridType", GridType.HEXAGON, geometry.getType());
    }
}
